package com.bean;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author: tgy
 * @Date: 2020-08-01 11:14
 */
public class BeanTest01 {

    private ApplicationContext applicationContext = null;

    @BeforeEach
    public void init(){

        applicationContext = new ClassPathXmlApplicationContext("/applicationContext.xml");

    }

    @Test
    public void test01(){


        Object singletonDog1 = applicationContext.getBean("com.bean.Dog#0");
        Object singletonDog2 = applicationContext.getBean("com.bean.Dog#1");

        System.out.println(singletonDog1);
        System.out.println(singletonDog2);

//        ClassPathXmlApplicationContext classPathXmlApplicationContext = (ClassPathXmlApplicationContext) applicationContext;

//        classPathXmlApplicationContext.close();
    }

    @Test
    public void test02(){

        Object personName = applicationContext.getBean("personName");

        System.out.println(personName);

    }
}
